var app = getApp();
Page({
	data: {
		type: 0,
		userCouponList: []
	},
	onLoad(options) {
		var $th = this;
		$th.loadlist()
	},
	type_select: function(e) {
		var that = this;
		var i = e.currentTarget.dataset.index;
		that.setData({
			type: i
		})
		that.loadlist()
	},
	loadlist: function() {
		var that = this;
		var t = that.data.type;
		if (t == 0) t = '';
		var data = {
			status: t
		}
		app.globalAjax(
			'/api/user/coupon',
			"get",
			data,
			function(e) {
				if (e.code == 0) {
					that.setData({
						userCouponList: e.userCouponList
					})
				} else {
					wx.showToast({
						title: e.msg,
						icon: "none"
					});
				}
			}
		)
	}
})
